home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: nababs@qualcomm.com (Nasser Abbasi)
- Newsgroups: comp.lang.c++.moderated,comp.lang.c++
- Subject: Re: enum expression is IF statement
- Date: 13 Feb 1996 23:51:38 -0000
- Organization: Qualcomm Inc.
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: devitto@ferndown.ate.slb.com
- Message-ID: <4fr86a$3su@netlab.cs.rpi.edu>
- References: <4fq7dc$pac@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: 13 Feb 1996 22:38:04 GMT
-
- In article <4fq7dc$pac@netlab.cs.rpi.edu>,
- P.v.Klaveren@bcs.cs.philips.com says...
- >
- >enum
- >{
- > CSEQ_IDLE,
- > CSEQ_ERROR,
- > CSEQ_ABORT,
- > CSEQ_WAIT4RESPONSE
- >};
- >
- >int state = 3;
- >
- >if (state == CSEQ_WAIT4RESPONSE)
- >{
- > // this code is not executed!!!
- > ...
- >}
- >
- >BOOL expr_is_valid = state == CSEQ_WAIT4RESPONSE;
- >
- >if (expr_is_valid)
- >{
- > // this code IS executed!!!
- > ...
- >}
- >
- >
- >I know it is not recommended to compare integers with enumeration
- >values, but why on earth is 'expr_is_valid' TRUE but seems
- >'state == CSEQ_WAIT4RESPONSE' to result in FALSE (at least in a if
- >expression calcuation)?
- >
-
- The code works fine on my C++ compiler (Visuall C++ 1.51).
- i.e. both IF statments above get executed (as one would expect).
-
- can you post a small complete example (with #include statments) that
- shows the problem?
-
- what compiler are you using?
-
- Nasser
-
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-